﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _89数组_二维数组
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            int[,] array = new int[4, 3];//创建一个4行3列的二维数组
            array[0, 0] = 5;
            array[2, 1] = 3;

            //先遍历行
            for (int r = 0; r < array.GetLength(0); r++)//GetLength(0)获取行长度
            {
                for (int c = 0; c < array.GetLength(1); c++)//遍历列
                {
                    Console.Write(array[r, c] + "\t");
                }
                Console.Write("\n");
            }

            Console.WriteLine("------------------------------------------------");

            //从右下角开始水平遍历
            for (int r = array.GetLength(0) - 1; r >= 0; r--)
            {
                for (int c = array.GetLength(1) - 1; c >= 0; c--)
                {
                    Console.Write(array[r, c] + "\t");
                }
                Console.WriteLine();
            }

            //左上水平
            //左上垂直
            //四个角落 每个角落两种遍历,总共八种遍历
        }
    }
}